-
Notifications
You must be signed in to change notification settings - Fork 2k
Add async support for dspy.Evaluate #8504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add async support for dspy.Evaluate #8504
Conversation
queue.task_done() | ||
|
||
workers = [asyncio.create_task(worker()) for _ in range(num_threads)] | ||
await asyncio.gather(*workers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: Does acyncio.gather
use multiple threads with this setup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't use multiple threads, but does put those async workers to run asynchronously in the same event loop.
dspy/evaluate/evaluate.py
Outdated
num_threads: int, | ||
): | ||
queue = asyncio.Queue() | ||
results = [None for _ in range(len(devset))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
results = [None for _ in range(len(devset))] | |
results = [None] * len(devset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
Wow so cool! |
Should this be added to dspy.Evaluate or deeper, like dspy.ParallelExecutor |
The I am not quite sure if we should have an async version of |
We are introducing:
_execute_with_multithreading
for running evaluation in multithreading_execute_with_event_loop
for running evaluation in async concurrency.The weird part is although technically async eval should run faster than multithreading because evaluation is IO bound task, but I am not noticing it consistently.
Testing script is pasted below:
70% time async runs faster than multithreading insignificantly, and 30% time it's the reverse. Two potential theories: